package com.hitech;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

import javax.annotation.PostConstruct;

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class Application {
	@Autowired
	private SimpleRabbitListenerContainerFactory simpleRabbitListenerContainerFactory;

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

	@PostConstruct
	public void init() {
		simpleRabbitListenerContainerFactory.setTaskExecutor(rabbitmqTaskExecutor());
	}

	@Bean("rabbitmqTaskExecutor")
	public Executor rabbitmqTaskExecutor() {
		return Executors.newFixedThreadPool(10);
	}
}
